<template>
	<view class="content">
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id">
					<view class="title-item">
						<view class="round" style="background-color: #FFA101;" v-if="item.statusText==='黄灯单位'"></view>
						<view class="round" style="background-color: #127DFF;" v-else-if="item.statusText==='蓝灯单位'">
						</view>
						<view class="round" style="background-color: #FE0000;" v-else-if="item.statusText==='红灯单位'">
						</view>
						<view class="name">{{index+1}}、{{item.unitName}}</view>
					</view>
					<view class="progress-block">
						<view class="name-block">
							<view class="name"><text class="title">分类：</text>{{item.typeText}}</view>
							<!-- <view class="time">{{item.tasks}}万元</view> -->
						</view>
						<view class="name-block">
							<view class="name"><text class="title">完成比例：</text></view>
						</view>
						<progress :percent="item.rate" border-radius="20rpx" :stroke-width="8" activeColor="#0050FC"
							backgroundColor="#efefef"></progress>
						<view class="phase" v-if="item.rate<100&&item.rate>10"><text
								:style="'left:calc('+item.rate+'% - 80rpx)'">{{item.rate}}%</text>
						</view>
						<view class="phase" v-else-if="item.rate<=10"><text
								:style="'left:calc('+item.rate+'% - 10rpx)'">{{item.rate}}%</text>
						</view>
						<view class="phase" v-else-if="item.rate>=100"><text
								:style="'left:calc('+item.rate+'% - 200rpx)'">{{item.rate}}%</text>
						</view>
					</view>
					<view class="amount-list">
						<view class="amount-item">
							<view class="money">{{item.taskPlan}}万元</view>
							<view class="text">任务金额</view>
						</view>
						<view class="thread"></view>
						<view class="amount-item">
							<view class="money">{{item.completionFunds}}万元</view>
							<view class="text">完成金额</view>
						</view>
					</view>
				</view>
			</template>
			<view v-else style="text-align: center;">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		selectBusinessById
	} from '@/api/search.js'

	export default {
		data() {
			return {
				list: []
			}
		},
		methods: {
			getList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				selectBusinessById({
					departmentId: this.id
				}).then(data => {
					uni.hideLoading()
					this.list = data || []
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},

		onLoad(e) {
			this.id = e.id
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		min-height: 100vh;
		background: #F5F5F5;

		.info-block {
			display: flex;
			flex-direction: column;
			border-radius: 40rpx;
			height: auto;
			position: relative;
			padding: 30rpx;

			.sort-item {
				display: flex;
				flex-direction: row;
				margin-bottom: 30rpx;
				display: flex;
				justify-content: flex-end;

				.order-item {
					background-color: #E5E5E5;
					margin-left: 20rpx;
					border-radius: 40rpx;
					padding: 10rpx 20rpx;
					font-size: 28rpx;
				}

				.order-item.active {
					background-color: #0056FF;
					color: #fff;
				}
			}

			.tips {
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 30rpx;
				border-radius: 20rpx;
				margin-bottom: 30rpx;

				.img {
					width: 45rpx;
					height: 45rpx;
					margin-right: 20rpx;
				}

				.text {
					font-size: 32rpx;
					width: calc(100% - 80rpx);

					.total {
						font-weight: bold;
					}
				}
			}

			.info-item {
				height: auto;
				box-shadow: 0 0 10px 0 #dedede;
				background: #fff;
				display: flex;
				flex-direction: column;
				border-radius: 20rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;

				.title-item {
					display: flex;
					flex-direction: row;
					align-items: center;

					.round {
						width: 36rpx;
						height: 36rpx;
						border-radius: 50%;
						margin-top: 12rpx;
						margin-right: 15rpx;
						margin-bottom: 36rpx;
					}

					.name {
						font-weight: bold;
						font-size: 34rpx;
						margin-bottom: 30rpx;
					}
				}


				.progress-block {
					display: flex;
					flex-direction: column;
					background-color: #F5F5F5;
					padding: 30rpx;
					border-radius: 20rpx;

					.name-block {
						display: flex;
						flex-direction: row;
						align-items: center;

						.name {
							font-weight: normal;
							flex-grow: 1;
							font-size: 30rpx;
							margin-bottom: 20rpx;

							.title {
								color: #999;

							}
						}

						.time {
							flex-grow: 0;
							color: #0050FC;
							font-size: 28rpx;
						}
					}

					.phase {
						margin: 10rpx auto;
						height: 40rpx;
						width: 100%;
						position: relative;

						text {
							font-size: 28rpx;
							position: absolute;
							color: #0050FC;
						}
					}
				}

				.amount-list {
					display: flex;
					flex-direction: row;
					justify-content: center;
					align-items: center;

					.amount-item {
						display: flex;
						flex-direction: column;
						margin: 30rpx;

						.money {
							font-weight: bold;
						}

						.text {
							color: #999;
							font-size: 28rpx;
						}
					}

					.thread {
						width: 3rpx;
						height: 40rpx;
						border-radius: 4rpx;
						background-image: linear-gradient(#fff, #999, #fff);
					}
				}
			}
		}
	}
</style>